package factory.simpleFactory;

/**
 * @Author: Doream
 * @Date: 2022/1/27 22:45
 */

// 简单工厂模式(它并不属于23种设计模式，更像是编程习惯)
// 由工厂来接管创建对象的过程，实现解耦合
public class MilkTeaFactory {
    public MilkTea createMilkTea(String type) {
        return createMilkTea(type, 8, "温");
    }

    public MilkTea createMilkTea(String type, int sweetness) {
        return createMilkTea(type, sweetness, "温");
    }

    public MilkTea createMilkTea(String type, int sweetness, String temperature) {
        if (type.equals("焦糖奶茶")) {
            return new CaramelMilkTea(sweetness, temperature);
        } else {
            return new RedBeanMilkTea(sweetness, temperature);
        }
    }
}
